var RunLayer_12 = cc.Layer.extend({
	arr:null,
	scene:null,
	clock:null,
	ctor:function (parent) {
		this._super();
		this.scene = parent;
		this.scene.addChild(this, 10);
		gg.main = this;
		this.init();
	},
	init:function () {
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callKill = cc.callFunc(function(p){
			var seq = cc.sequence(cc.fadeOut(0.5),cc.callFunc(function(){
				p.removeFromParent(true);	
			}, this));
			p.runAction(seq);
		}, this); 

		this.callNext.retain();
		this.callKill.retain();
		//时钟
		this.clock = new Clock(this);
		// 物品库
		this.lib = new Lib(this);
		this.lib.loadBg([
		                 {tag:TAG_LIB_CONICAL},
		                 {tag:TAG_LIB_BEAKER,checkright:true},
		                 {tag:TAG_LIB_SAND,checkright:true},
		                 {tag:TAG_LIB_NET,checkright:true},
		                 {tag:TAG_LIB_PIPE},
		                 {tag:TAG_LIB_LAMP,checkright:true},
		                 {tag:TAG_LIB_SHELF,checkright:true},
		                 {tag:TAG_LIB_TESTTUBE},
		                 {tag:TAG_LIB_VOLUMETRIC},
		                 {tag:TAG_LIB_TEMPERATURE,checkright:true},
		                 ]);
		//实战中，默认出lib，得分字不出
		ll.tip.scoreLabel.setVisible(false);
		this.loadShelfLeft();
		this.loadShelfRight();
		//酒精灯
		this.lamp = new Lamp(this);
		//温度计
		this.temp = new Temp(this);
		//烧杯
		this.beaker = new Beaker(this);
		//等质量提示
		this.word();
	},
	word : function() {
		var word = new cc.LabelTTF("等质量的水和砂石",gg.fontName,28);
		word.setPosition(cc.p(665,340));
		this.addChild(word,2,TAG_DENGZHILIANG);
		word.setVisible(false);
	},
	loadShelfLeft:function(){
		//铁架台（左边）--水
		var shelf1 = new cc.Sprite("#run/shelf_left_body.png");
		this.addChild(shelf1, 20,TAG_SHELF_LEFT_BODY);
		shelf1.setPosition(cc.p(gg.width*0.35,gg.height*0.43));
		shelf1.setScale(0.7);
		shelf1.setVisible(false);
		//上面（放温度计）
		var shelf2 = new cc.Sprite("#run/shelf_left_jiazi1.png");
		shelf1.addChild(shelf2, 23,TAG_SHELF_LEFT_JIAZI1);
		shelf2.setPosition(cc.p(128,657));
		shelf2.setScale(0.6);
		//下面（放烧杯）
		var shelf3 = new cc.Sprite("#run/shelf_left_jiazi2.png");
		this.addChild(shelf3, 22,TAG_SHELF_LEFT_JIAZI2);
		shelf3.setPosition(cc.p(402,305));
		shelf3.setScale(0.7);
		shelf3.setVisible(false);
		//中间（石棉网）
		var net = new cc.Sprite("#lib/net.png");
		shelf3.addChild(net,3,TAG_SHELF_LEFT_NET1);
		net.setPosition(cc.p(239,54));
		
		shelf1.setCascadeOpacityEnabled(true);
	},
	loadShelfRight:function(){
		//铁架台（右边）--砂石
		var shelf4 = new cc.Sprite("#run/shelf_right_body.png");
		this.addChild(shelf4, 20,TAG_SHELF_RIGHT_BODY);
		shelf4.setPosition(cc.p(gg.width*0.7,gg.height*0.43));
		shelf4.setScale(0.7);
		shelf4.setVisible(false);
		//上面（放温度计）
		var shelf5 = new cc.Sprite("#run/shelf_right_jiazi1.png");
		shelf4.addChild(shelf5, 23,TAG_SHELF_RIGHT_JIAZI1);
		shelf5.setPosition(cc.p(266,657));
		shelf5.setScale(0.6);
		//下面（放烧杯）
		var shelf6 = new cc.Sprite("#run/shelf_right_jiazi2.png");
		this.addChild(shelf6, 22,TAG_SHELF_RIGHT_JIAZI2);
		shelf6.setPosition(cc.p(936,305));
		shelf6.setScale(0.7);
		shelf6.setVisible(false);
		//中间（石棉网）
		var net = new cc.Sprite("#lib/net.png");
		shelf6.addChild(net,3,TAG_SHELF_RIGHT_NET2);
		net.setPosition(cc.p(93,40));
		
		shelf4.setCascadeOpacityEnabled(true);
	},
	checkVisible:function(next){
		//是否可见
		var checkVisible = [];
		var shelf_left = this.getChildByTag(TAG_SHELF_LEFT_BODY);
		var shelf_left_jiazi = this.getChildByTag(TAG_SHELF_LEFT_JIAZI2);
		var shelf_right = this.getChildByTag(TAG_SHELF_RIGHT_BODY);
		var shelf_right_jiazi = this.getChildByTag(TAG_SHELF_RIGHT_JIAZI2);
		var lamp = ll.run.lamp;
		var temp = ll.run.temp;
		var beaker = ll.run.beaker;
		var show = ll.run.getChildByTag(TAG_SHOW);
		var word = this.getChildByTag(TAG_DENGZHILIANG);
		checkVisible.push(shelf_left, shelf_left_jiazi,shelf_right, shelf_right_jiazi,
				lamp, temp, beaker, show, word);

		for(var i in checkVisible){
			if(checkVisible[i] !== null){				
				checkVisible[i].setVisible(next);				
			}			
		}
	},
	loadInLib:function(obj, pos, tarPos,delay){
		obj.setPosition(pos);
		if(delay == null){
			delay = 1;
		}
		var ber = $.bezier(pos, tarPos, delay);
		var seq = cc.sequence(ber, this.callNext);
		obj.runAction(seq);
	},
	kill:function(obj){
		var fade = cc.fadeTo(0.5,0);
		var func = cc.callfunc(function(){
			obj.removeFromParent(true);
		},this);
		var seq = cc.sequence(fade,func);
		obj.runAction(seq)
	},

	callback:function (p){
		var func = cc.callFunc(this.actionDone, this);
		var action=gg.flow.flow.action;
		switch(p.getTag()){
		case TAG_XIANGPISAI:

			break;

		}
	},
	actionDone:function(p){
		var func = cc.callFunc(this.actionDone, this);
		switch(p.getTag()){

		}
	},
	flowNext:function(){
		gg.flow.next();
	},
	onExit:function(){
		this._super();
		this.callNext.release();
		this.callKill.release();
	}
});